package com.teemor.tim.command.handler.customer;


import com.teemor.tim.command.model.customer.DisConnectCommandd;
import com.teemor.tim.processor.CustomerServiceProcessor;
import com.teemor.tim.model.user.UserStateModel;
import com.teemor.tim.command.annation.CommandMapping;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @ename zhoulk
 * @cname 周李科
 * @date 2020/12/15 17:19
 */

@CommandMapping("CS")
@Slf4j
public class CustomerServiceHandler {

    @Autowired
    private CustomerServiceProcessor customerServiceProcessor;

    @CommandMapping("CsDisconnect")
    public void csDisconnect(DisConnectCommandd command) {
        List<UserStateModel> userStateModelList = command.getUserStateModels();
        userStateModelList.forEach(userModel -> {
            userModel.setSessionUsers(new ArrayList<>());
            customerServiceProcessor.selectSeat(userModel.getUserId());
        });
    }

}
